package com.hsh;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.util.ReferenceCountUtil;

import java.util.concurrent.TimeUnit;

/**
 * @author: shaohai.huang
 * @date: 2019-10-09
 */
public class test {

    public static void main(String[] args) {
        final PooledByteBufAllocator aDefault = PooledByteBufAllocator.DEFAULT;
        final ByteBuf buffer = aDefault.buffer(4);
        new Thread(new Runnable() {
            @Override
            public void run() {
                buffer.writeInt(10);
                try {
                    TimeUnit.SECONDS.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                final int i = buffer.readInt();
                System.out.println(i);
                buffer.isReadable();
            }
        }).start();

        System.out.println(ReferenceCountUtil.release(buffer));
        System.out.println("end");
    }

}
